<template>
  <div class="app-container">
          <!--<eHeader :query="query" :dict="dict" :sup_this="sup_this"/>-->
          <el-button size="mini" type="success" @click="to">编辑</el-button>
          <!--表格渲染-->
          <el-table v-loading="loading" :data="data" size="small" style="width: 100%;" @selection-change="handleSelectionChange">
            <el-table-column
              type="selection"
              width="55">
            </el-table-column>
            <el-table-column fixed prop="deviceName" label="设备名称" min-width="120"/>
            <el-table-column prop="deviceIp" label="设备IP" min-width="120"/>
            <el-table-column prop="devicePort" label="设备端口"/>
            <!--<el-table-column prop="username" label="用户名"/>-->
            <!--<el-table-column prop="password" label="密码"/>-->
            <el-table-column label="设备区域">
              <template slot-scope="scope">
                <div v-for="item in dict.area" :key="item.id">
                  <span v-if="scope.row.deviceArea==item.id">{{ item.areaName }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="inOutFlag" label="进出标识">
              <template slot-scope="scope">
                <div v-for="item in dict.in_out_flag" :key="item.id">
                  <span v-if="scope.row.inOutFlag==item.value">{{ item.label }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="attendance" label="是否考勤">
              <template slot-scope="scope">
                <div v-for="item in dict.is_no" :key="item.id">
                  <span v-if="scope.row.attendance==item.value">{{ item.label }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="deviceModel" label="设备型号"/>
            <el-table-column prop="deviceNum" label="设备编号"/>
            <el-table-column prop="deviceGrade" label="设备级别"/>
            <el-table-column prop="deviceBrand" label="设备品牌"/>
            <el-table-column prop="manufacturer" label="设备厂商"/>
          </el-table>
          <!--分页组件-->
          <el-pagination
            :total="total"
            style="margin-top: 8px;"
            layout="total, prev, pager, next, sizes"
            @size-change="sizeChange"
            @current-change="pageChange"/>
  </div>
</template>

<script>
  import initData from '@/mixins/initData'
  import {del, getDict} from '@/api/accessDevice'
  import {parseTime} from '@/utils/index'
//  import eHeader from './module/header'
  export default {
//    components: {eHeader, myArea},
    mixins: [initData],
    data() {
      return {
        height: document.documentElement.clientHeight - 104 + 'px;',
        delLoading: false, sup_this: this,
        dict: {}
      }
    },
    created() {
      this.$nextTick(() => {
        this.init()
        this.getDict()
      })
    },
    methods: {
      parseTime,
      getDict(){
        getDict().then(res => {
          this.dict = res
        }).catch(err => {
          console.log(err.response.data.message)
        })
      },
      beforeInit() {
        this.url = 'api/accessDevice'
        const sort = 'id,desc'
        this.params = {page: this.page, size: this.size, sort: sort}
        const query = this.query
        const deviceName = query.deviceName
        const deviceArea = query.deviceArea
        if (deviceName) {
          this.params['deviceName'] = deviceName
        }
        if (deviceArea) {
          this.params['deviceArea'] = deviceArea
        }
        return true
      }
    }
  }
</script>

<style scoped>

</style>
